/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package skelbkim;

import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;

/**
 *
 * @author laimis
 */
public class Look extends SeleneseTestCase {

    public void setUp() throws Exception {
        setUp("http://www.look.lt/lt/", "*firefox");
    }

    public void newNotation(String noticeText, String phone, String name, String noticeTitle, String email) throws Exception {
        selenium.open("/lt/?part=look.lt&new_advertise=show");
        if (isPageLoude()) {
            selenium.type("clientname", name);
            selenium.select("city", "label=Klaipėda");
            selenium.type("email", email);
            selenium.type("tel", phone);
            selenium.type("heading", noticeTitle);
            selenium.select("category", "label=WWW svetainės");
            selenium.select("type", "label=Siūlau");
            selenium.type("text", noticeText);
            selenium.select("expire", "label=1 mėn.");
            selenium.click("//input[@name='submit' and @value='Skelbtis']");
        }
        selenium.stop();
    }

    private boolean isPageLoude() {
        boolean result = true;
        while (!selenium.isElementPresent("//table[4]/tbody/tr/td[3]/table/tbody/tr/td/form/table/tbody/tr[23]/td[2]/input")) {
            selenium.waitForPageToLoad("5000");
        }
        return result;
    }
}

